<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>자료실 상세보기</title>
<script type="text/javascript">
	$(function() {
		$("#modifyBtn").click(function() {
			location.href="${initParam.root}/board_goUpdateFileBoard.do?fileNo=${requestScope.fvo.fileNo}";
		});
		
		$("#deleteBtn").click(function() {
			location.href="${initParam.root}/board_erasureFileBoard.do?fileNo=${requestScope.fvo.fileNo}&fileName=${requestScope.fvo.fileName}";
		});
	});
	function downloadFile(filename){
		alert(filename);
		if(confirm(filename+" 다운로드하시겠습니까?")){
			location.href="${initParam.root}/board_fileDownload.do?filename="+filename;
		} else {
			return false;
		}
	}
</script>
</head>
<body>
<center>
<h2>자료실</h2>
	<table rules="all">
		<tr>
			<td>No ${requestScope.fvo.fileNo }</td><td colspan="2">${requestScope.fvo.fileTitle }</td>
		</tr>
		<tr>
			<td>Writer ${requestScope.fvo.fileWriter }</td><td>Date ${requestScope.fvo.fileDate }</td><td>Count ${requestScope.fvo.fileCount }</td>
		</tr>
		<tr>
			<td colspan="3"><textarea id="fileContent" rows="10" cols="60" style="resize:none" readonly="readonly">${requestScope.fvo.fileContent }</textarea></td>
		</tr>
		<tr><td colspan="3">
		<c:choose>
			<c:when test="${requestScope.fvo.fileName != null }">
				<a href="javascript:downloadFile('${requestScope.fvo.fileName }')">${requestScope.fvo.fileName }</a>
			</c:when>
			<c:otherwise>
				해당 글엔 업로드된 파일이 없습니다!!
			</c:otherwise>
		</c:choose>
		</td></tr>
	</table><br><br>
	<c:if test="${sessionScope.mvo.id==requestScope.fvo.fileWriter }">
		<input type="button" value="수정" id="modifyBtn">
		<input type="button" value="삭제" id="deleteBtn">
	</c:if>
	</center>
</body>
</html>